$(function () {

    //获取验证码
    function getCode(phone) {
        if(phoneNumberVer(phone)){
            getData('post','/niu/api/member_login_sms_wx.php',{'phone':phone},function (data) {
                console.log(data);
                if(data.resultcode == 0){
                    laymsg(data.msg);
                    //倒计时
                    var second = 60;
                    var timer = null;
                    timer = setInterval(function(){
                        second -= 1;
                        if(second > 0 ){
                            $('.codeBtnActive').hide();
                            $('.codeBtn').html(second+'秒').show();
                        }else{
                            clearInterval(timer);
                            $('.codeBtn').hide();
                            $('.codeBtnActive').show();
                        }
                    },1000);
                }else {
                    laymsg(data.msg)
                }
            })
        }
    }

    $('.codeBtnActive').click(function () {
        var phone = $('#phoneNum').val();
        getCode(phone);
    });
    
    $('#codeLogin').click(function () {
        $('.codeLoginHtml').fadeIn();
    });
    $('#close').click(function () {
        $('.codeLoginHtml').fadeOut();
    })
});